toNotBlankStringOrNull
@ExperimentalSinceKotoolsTypes(version = "4.3.1")
Returns this string as a NotBlankString, or returns null
if this string is blank.
Here's some usage examples:
var result: NotBlankString? = "hello world".toNotBlankStringOrNull()
println(result) // hello world
result = " ".toNotBlankStringOrNull()
println(null) // null
Content copied to clipboard
You can use the toNotBlankStringOrThrow function for throwing an IllegalArgumentException instead of returning null
when this string is blank.